package com.tark.service.qrcode.util.model;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.annotation.JSONField;
import com.tark.service.qrcode.util.constant.ResultStatusEnum;



public class ApiResult {
	@JSONField(ordinal=1)
	private long timestamp;

	@JSONField(ordinal=2)
	private String statusCode;

	@JSONField(ordinal=3)
	private String statusName;
	
	@JSONField(ordinal=4)
	private String message;
	
	@JSONField(ordinal=5)
	private String exception;

	@JSONField(ordinal=6)
	private String url;

	@JSONField(ordinal=7)
	private Map<String, Object> body;

	public ApiResult() {
		this.timestamp = System.currentTimeMillis();

		if (body == null) {
			body = new HashMap<String, Object>();
		}
	}

	public ApiResult(ResultStatusEnum resultStatus, String message, String exception, String url,
			Map<String, Object> body) {
		this.timestamp = System.currentTimeMillis();
		this.statusCode = resultStatus.getCode();
		this.statusName = resultStatus.getName();
		this.message = message;
		this.exception = exception;
		this.url = url;

		if (body != null) {
			this.body = body;
		} else {
			body = new HashMap<String, Object>();
		}
	}

	public ApiResult(String statusCode, String statusName, String message, String exception, String url,
			Map<String, Object> body) {
		this.timestamp = System.currentTimeMillis();
		this.statusCode = statusCode;
		this.statusName = statusName;
		this.message = message;
		this.exception = exception;
		this.url = url;

		if (body != null) {
			this.body = body;
		} else {
			body = new HashMap<String, Object>();
		}
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public String getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}

	public String getStatusName() {
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getException() {
		return exception;
	}

	public void setException(String exception) {
		this.exception = exception;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Map<String, Object> getBody() {
		return body;
	}

	public void setBody(Map<String, Object> body) {
		this.body = body;
	}

}
